import request from "@/utils/request";

/** 登录 */
export function login(data) {
  return request({
    url: "/login",
    method: "post",
    data,
  });
}

/** 添加管理员 */
export function addAdminAPI(data) {
  return request({
    url: "/register",
    method: "post",
    data,
  });
}

/** 获取资料 */
export function getUserInfo() {
  return request({
    url: "/getUserInfo",
    method: "get",
  });
}

/** 角色列表选项option */
export function roleListOptionAPI() {
  return request({
    url: "/role/list/option",
    method: "get",
  });
}

/** 角色列表 */
export function roleListAPI(data) {
  return request({
    url: "/role/list",
    method: "get",
    params: data
  });
}

/** 更新管理员信息 */
export function updateAdminAPI(data) {
  return request({
    url: "/admin/update",
    method: "put",
    data,
  });
}

/** 删除管理员 */
export function deleteAdminAPI(id) {
  return request({
    url: `/admin/delete/${id}`,
    method: "delete",
  });
}

/** 权限列表 */
export function permissionLisAPI() {
  return request({
    url: "/permission/list",
    method: "get",
  });
}

/** 获取某个管理员的权限点 */
export function getRolePermissionsAPI(id) {
  return request({
    url: "/role/permissions",
    method: "get",
    params: {
      id,
    },
  });
}

/** 更新某个管理员的权限点 */
export function updateRolePermissionsAPI(data) {
  return request({
    url: "/role/permissions",
    method: "put",
    data
  });
}
// /role/permissions
export function deleteRolePermissionsAPI(data){
  return request({
    url:"/role/permissions",
    method:'delete',
    data
  })
}
/** 更新角色信息 */
export function updateRoleAPI(data) {
  return request({
    url: "/role/update",
    method: "put",
    data
  });
}

/** 添加角色 */
export function addRole(data){
  return request({
    url: "/role/add",
    method: "post",
    data
  });
}

/** 更新管理员CMS导航栏信息 */
export function updateCmsNavAdminAPI(data) {
  return request({
    url: '/nav/update',
    method: "put",
    data,
  });
}

export function EnableAdmin(id) {
  return request({
    url: '/admin/enable',
    method: "post",
    data:{
      id
    },
  });
}